efi: optionally call SetVirtualAddressMap()
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fri, 25 Oct 2019 15:49:28 +0000 (17:49 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 25 Oct 2019 15:49:28 +0000 (17:49 +0200)
commit49450415d6ba646c34d62605457cff36bc4b52ed
treedcbde2f71f3467855fd3b80fa5e2a417a34be396
parent86cf0ed11cdbf7b99a88312076ff455386c3bc22
efi: optionally call SetVirtualAddressMap()

Some UEFI implementations are not happy about lack of
SetVirtualAddressMap() call. Likely abuse the address map change
notification to do things beyond the necessary ConvertPointer() calls.
Specifically, wihtout the SetVirtualAddressMap() call, some access
EfiBootServices{Code,Data}, or even totally unmapped areas. Example
crash of GetVariable() call on Thinkpad W540:

    Xen call trace:
       [<0000000000000080>] 0000000000000080
       [<8c2b0398e0000daa>] 8c2b0398e0000daa

    Pagetable walk from ffffffff858483a1:
       L4[0x1ff] = 0000000000000000 ffffffffffffffff

    ****************************************
    Panic on CPU 0:
    FATAL PAGE FAULT
    [error_code=0002]
    Faulting linear address: ffffffff858483a1
    ****************************************

Fix this by calling SetVirtualAddressMap() runtime service, giving it
1:1 map for areas marked as needed during runtime. The address space in
which EFI runtime services are called is unchanged, but UEFI view of it
may be.
Since it's fairly late in Xen 4.13 development cycle, disable it
by default and hide behind EXPERT.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/common/Kconfig
xen/common/efi/boot.c